package top.readhub.wopei.example.controller;

import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.readhub.wopei.client.WoPei;
import top.readhub.wopei.example.dto.Demo;

import java.util.List;

@RestController
@RequestMapping("/example")
public class TestController {

    @RequestMapping("/test")
    public String test(@RequestBody String code) {
        return WoPei.get(code);
    }

    @RequestMapping("/test2")
    public Demo test2(@RequestBody String code) {
        return WoPei.get(code, Demo.class);
    }

    @RequestMapping("/test3")
    public String test3(@RequestBody String code) {
        return WoPei.getByRemote(code);
    }

    @RequestMapping("/test4")
    public List<Demo> test4(@RequestBody String code) {
        return WoPei.getAllByRemote(code, new TypeReference<List<Demo>>() {
        });
    }
}
